import spring from "@/res/spring.js";
const base_url = '/Blog/';
const base_status_url = '/BlogStatus/';

function http(url){
    return base_url+url
}
function http_status(url){
    return base_status_url+url
}

//  获取博客列表
function getAllBlogByPostType(params){
    return spring({
        url: http('BlogSort'),
        method: 'POST',
        data: params
    })
}

// 根据文章ID/文章标题/文章作者ID获取文章信息
function BlogSelect(params){
    return spring({
        url: http('BlogSelect'),
        method: 'POST',
        data: params
    })
}

//通过文章id获取文章
function getBlogByPostsId(params){
    return spring({
        url: http('getBlogByPostsId'),
        method: 'POST',
        params: params
    })
}

// 得到文章作者信息
function getUserCardByUuidForPosts(params){
    return spring({
        url: "/userCard/getUserCardByUuidForPosts",
        method: 'POST',
        params: params,
        headers: {'Content-Type':'multipart/form-data'}
    })
}

// 增加浏览量
function addBrowse(params){
    return spring({
        url: http_status('views'),
        method: 'POST',
        params: params
    })
}

// 创建文章
function createBlog(params){
    return spring({
        url: http('BlogCreate'),
        method: 'POST',
        params: params
    })
}

export {
    getAllBlogByPostType, BlogSelect,getBlogByPostsId,addBrowse,getUserCardByUuidForPosts,createBlog
}
